{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import warnings\n",
    "import matplotlib\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "from scipy.special import jn\n",
    "from IPython.display import display, clear_output\n",
    "import time\n",
    "from datetime import datetime\n",
    "warnings.filterwarnings('ignore')\n",
    "\n",
    "##调取若干模型\n",
    "from sklearn import linear_model\n",
    "from sklearn.linear_model import LinearRegression,SGDRegressor\n",
    "from sklearn import preprocessing\n",
    "from sklearn.svm import SVR\n",
    "from sklearn.ensemble import RandomForestRegressor,GradientBoostingRegressor\n",
    "import lightgbm as lgb\n",
    "import xgboost as xgb\n",
    "\n",
    "from sklearn.model_selection import GridSearchCV,cross_val_score,StratifiedKFold,train_test_split\n",
    "from sklearn.metrics import mean_squared_error, mean_absolute_error"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "#相关系数分析\n",
    "def draw_scatter(x, y, colname, name, corr):\n",
    "    plt.figure(figsize=(4, 2.5), dpi=300)\n",
    "    plt.rcParams['font.sans-serif'] = ['Arial Unicode MS']\n",
    "    plt.tick_params(labelsize=3)\n",
    "    plt.scatter(x, y, s=3)\n",
    "    plt.xlabel(\"Price\", fontsize=3)\n",
    "    plt.ylabel(colname, fontsize=3)\n",
    "    plt.title(\"price与\"+colname +\"相关系数：\"+str(round(corr,2)))\n",
    "    plt.savefig(\"C:/Users/12594/Desktop/BuyCarAnalyse/data/\" + name + \".png\")\n",
    "    plt.show()\n",
    "\n",
    "#日期读取\n",
    "def cal_days(date):\n",
    "    try:\n",
    "        date = datetime.strptime(str(date), '%Y%m%d')\n",
    "    except:\n",
    "        year = str(date)[:4]\n",
    "        month = int(str(date)[4:6])\n",
    "        day = int(str(date)[6:])\n",
    "        if month < 1:\n",
    "            month = \"01\"\n",
    "        elif month > 12:\n",
    "            month = \"12\"\n",
    "        if day < 1:\n",
    "            day = \"01\"\n",
    "        elif day > 31:\n",
    "            day = \"31\"\n",
    "        date = datetime.strptime(str(year)+str(month)+str(day), '%Y%m%d')\n",
    "    return (datetime.now()-date).days\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train data shape: (150000, 30)\n",
      "Test data shape: (50000, 29)\n",
      "['gearbox', 'regDays', 'power', 'kilometer', 'v_0', 'v_3', 'v_4', 'v_5', 'v_8', 'v_9', 'v_10', 'v_11', 'v_12']\n"
     ]
    }
   ],
   "source": [
    "## 通过Pandas对于数据进行读取 \n",
    "Train_data = pd.read_csv(r'C:/Users/12594/Desktop/project/used_car_train_20200313.csv', index_col=0, sep=' ')\n",
    "Test_data = pd.read_csv(r'C:/Users/12594/Desktop/project/used_car_testB_20200421.csv',  index_col=0, sep=' ')\n",
    "\n",
    "## 输出数据的大小信息\n",
    "print('Train data shape:',Train_data.shape)\n",
    "print('Test data shape:',Test_data.shape)\n",
    "\n",
    "Train_data[\"regDays\"] = Train_data[\"regDate\"].apply(cal_days)\n",
    "Train_data[\"createDays\"] = Train_data[\"creatDate\"].apply(cal_days)\n",
    "Test_data[\"regDays\"] = Test_data[\"regDate\"].apply(cal_days)\n",
    "Test_data[\"createDays\"] = Test_data[\"creatDate\"].apply(cal_days)\n",
    "\n",
    "#带入先验知识，选择相关列\n",
    "col_names = [\"gearbox\",\"regDays\",\"power\",\"kilometer\",\"createDays\", \"v_0\", \"v_1\", \"v_2\", \"v_3\", \"v_4\", \"v_5\", \"v_6\", \"v_7\", \"v_8\", \"v_9\", \"v_10\", \"v_11\", \"v_12\", \"v_13\", \"v_14\"]\n",
    "related_colnames = []\n",
    "#related_colnames = ['model', 'gearbox', 'power', 'kilometer',  'v_0', 'v_1', 'v_2', 'v_3', 'v_4', 'v_5', 'v_6', 'v_7', 'v_8', 'v_9', 'v_10', 'v_11', 'v_12', 'v_13', 'v_14']\n",
    "for colname in col_names:\n",
    "    corr = Train_data[[\"price\", colname]].corr()[\"price\"].tolist()[1]\n",
    "    if abs(corr) >= 0.1:\n",
    "        related_colnames.append(colname)\n",
    "    #draw_scatter(x=Train_data[\"price\"], y=Train_data[colname], colname=colname, corr=corr, name=\"Price与\"+colname+\"关系图\")\n",
    "print(related_colnames)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "X train shape: (150000, 13)\n",
      "X test shape: (50000, 13)\n"
     ]
    }
   ],
   "source": [
    "##初始化训练样本与对应值+测试样本\n",
    "X_data = Train_data[related_colnames]\n",
    "Y_data = Train_data['price']\n",
    "X_test  = Test_data[related_colnames]\n",
    "print('X train shape:',X_data.shape)\n",
    "print('X test shape:',X_test.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 50000 entries, 200000 to 249999\n",
      "Data columns (total 13 columns):\n",
      " #   Column     Non-Null Count  Dtype  \n",
      "---  ------     --------------  -----  \n",
      " 0   gearbox    48032 non-null  float64\n",
      " 1   regDays    50000 non-null  int64  \n",
      " 2   power      50000 non-null  int64  \n",
      " 3   kilometer  50000 non-null  float64\n",
      " 4   v_0        50000 non-null  float64\n",
      " 5   v_3        50000 non-null  float64\n",
      " 6   v_4        50000 non-null  float64\n",
      " 7   v_5        50000 non-null  float64\n",
      " 8   v_8        50000 non-null  float64\n",
      " 9   v_9        50000 non-null  float64\n",
      " 10  v_10       50000 non-null  float64\n",
      " 11  v_11       50000 non-null  float64\n",
      " 12  v_12       50000 non-null  float64\n",
      "dtypes: float64(11), int64(2)\n",
      "memory usage: 5.3 MB\n"
     ]
    }
   ],
   "source": [
    "X_test.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "#统计函数\n",
    "def get_info(data):\n",
    "    print('最小值：',np.min(data))\n",
    "    print('最大值：',np.max(data))\n",
    "    print('平均值:',np.mean(data))\n",
    "    print('方差:',np.var(data))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "训练集价格分布情况\n",
      "最小值： 11\n",
      "最大值： 99999\n",
      "平均值: 5923.327333333334\n",
      "方差: 56279605.942732885\n"
     ]
    }
   ],
   "source": [
    "print('训练集价格分布情况')\n",
    "get_info(Y_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAD4CAYAAAAQP7oXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAUtElEQVR4nO3dbaxd1Z3f8e+v9piQTIlNcCLGRrVRrGkd1DbEIs6kGkVhCoZEMS9AMhoVN0NlNSVtZlppYpoXqEmQSDsaUtSECQqemCiDoUxaLAJ1LSAaVQoEM6Q8E9+BFO7AhJsaGDpRHpz598VZNzm5Ptd3cY/h+OH7kY7O3v+99t5r333tn/fe6xynqpAkqcffmXQHJEnHDkNDktTN0JAkdTM0JEndDA1JUrelk+7AkXbaaafVmjVrJt0NSTqmPPjggz+oqpULtTvuQmPNmjXs27dv0t2QpGNKkv/T087bU5KkboaGJKmboSFJ6mZoSJK6GRqSpG6GhiSpm6EhSepmaEiSuhkakqRux90nwsexZvs3Jrbv713zoYntW5J6eaUhSepmaEiSui0YGkl2JHkxyaNDtf+U5MkkDyf5b0mWDy27MslUkqeSnD9U39RqU0m2D9XXJrk/yf4ktyRZ1uontfmptnzNkTpo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AL0ZPncngL4Mp4L8CJ7X6m9r8VFt+5tD6n2rH9RRDo4WOxt8J4B8D+9q5/u8MRskc1+cZ+A/Ak61fX2UwAuq4Os/AzQye2fyUwZXB5W/EeZ1vH4d7+TUikqRu3p6SJHUzNCRJ3QwNSVI3Q0OS1M3QkCR1MzQkSd0MDUlSt/8PIaSJCKRLnwsAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#查看统计分布\n",
    "plt.hist(Y_data)\n",
    "plt.show()\n",
    "plt.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "#去掉NaN\n",
    "X_data = X_data.fillna(-1)\n",
    "X_test = X_test.fillna(-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "##若干模型函数\n",
    "#线性回归\n",
    "def build_model_lin(x_train,y_train):\n",
    "    linreg = LinearRegression()\n",
    "    model = linreg.fit(x_train,y_train)\n",
    "    return model\n",
    "#GradientTree Boosting\n",
    "def build_model_xgb(x_train,y_train):\n",
    "    model = xgb.XGBRegressor(n_estimators=150, learning_rate=0.1, gamma=0, subsample=0.8,\\\n",
    "        colsample_bytree=0.9, max_depth=9) \n",
    "    objective ='reg:squarederror'\n",
    "    model.fit(x_train, y_train)\n",
    "    return model\n",
    "\n",
    "def build_model_lgb(x_train,y_train):\n",
    "    estimator = lgb.LGBMRegressor(num_leaves=127,n_estimators = 150)\n",
    "    param_grid = {\n",
    "        'learning_rate': [0.01, 0.05, 0.1, 0.2],\n",
    "    }\n",
    "    gbm = GridSearchCV(estimator, param_grid)\n",
    "    gbm.fit(x_train, y_train)\n",
    "    return gbm\n",
    "\n",
    "def build_model_gbr(x_train,y_train):\n",
    "    gbrreg = GradientBoostingRegressor(n_estimators=150,learning_rate=0.1,max_depth=5)\n",
    "    model = gbrreg.fit(x_train,y_train)\n",
    "    return model\n",
    "\n",
    "def build_model_rfr(x_train,y_train):\n",
    "    rfrreg =  RandomForestRegressor(n_jobs = 1,random_state =1)#n_estimator = 100\n",
    "    model = rfrreg.fit(x_train,y_train)\n",
    "    return model\n",
    "\n",
    "def build_model_sgd(x_train,y_train):\n",
    "    sgdreg = SGDRegressor(max_iter=3000)\n",
    "    model = sgdreg.fit(x_train,y_train)\n",
    "    return model\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"\\n##五折交叉验证查看参数效果lgb\\nscores_train = []\\nscores = []\\nsk = StratifiedKFold(n_splits=5,shuffle=True,random_state=0)\\nfor train_ind,test_ind in sk.split(X_data,Y_data):\\n    train_x=X_data.iloc[train_ind].values\\n    train_y=Y_data.iloc[train_ind]\\n    test_x=X_data.iloc[test_ind].values\\n    test_y=Y_data.iloc[test_ind]\\n    model=build_model_lgb(train_x,train_y)\\n    model.fit(train_x,train_y)\\n    pred_train_lgb=model.predict(train_x)\\n    pred_lgb=model.predict(test_x)\\n    \\n    score_train = mean_absolute_error(train_y,pred_train_lgb)\\n    scores_train.append(score_train)\\n    score = mean_absolute_error(test_y,pred_lgb)\\n    scores.append(score)\\n\\nprint('Train mae:',np.mean(score_train))\\nprint('test mae',np.mean(scores))\\n\""
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "##五折交叉验证查看参数效果lgb\n",
    "scores_train = []\n",
    "scores = []\n",
    "sk = StratifiedKFold(n_splits=5,shuffle=True,random_state=0)\n",
    "for train_ind,test_ind in sk.split(X_data,Y_data):\n",
    "    train_x=X_data.iloc[train_ind].values\n",
    "    train_y=Y_data.iloc[train_ind]\n",
    "    test_x=X_data.iloc[test_ind].values\n",
    "    test_y=Y_data.iloc[test_ind]\n",
    "    model=build_model_lgb(train_x,train_y)\n",
    "    model.fit(train_x,train_y)\n",
    "    pred_train_lgb=model.predict(train_x)\n",
    "    pred_lgb=model.predict(test_x)\n",
    "    \n",
    "    score_train = mean_absolute_error(train_y,pred_train_lgb)\n",
    "    scores_train.append(score_train)\n",
    "    score = mean_absolute_error(test_y,pred_lgb)\n",
    "    scores.append(score)\n",
    "\n",
    "print('Train mae:',np.mean(score_train))\n",
    "print('test mae',np.mean(scores))\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"\\n##五折交叉验证查看参数效果xgb\\nscores_train = []\\nscores = []\\nsk = StratifiedKFold(n_splits=5,shuffle=True,random_state=0)\\nfor train_ind,test_ind in sk.split(X_data,Y_data):\\n    \\n    train_x=X_data.iloc[train_ind].values\\n    train_y=Y_data.iloc[train_ind]\\n    test_x=X_data.iloc[test_ind].values\\n    test_y=Y_data.iloc[test_ind]\\n    \\n    model=build_model_xgb(train_x,train_y)\\n    model.fit(train_x,train_y)\\n    pred_train_xgb=model.predict(train_x)\\n    pred_xgb=model.predict(test_x)\\n    \\n    score_train = mean_absolute_error(train_y,pred_train_xgb)\\n    scores_train.append(score_train)\\n    score = mean_absolute_error(test_y,pred_xgb)\\n    scores.append(score)\\n\\nprint('Train mae:',np.mean(score_train))\\nprint('Val mae',np.mean(scores))\\n\""
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "##五折交叉验证查看参数效果xgb\n",
    "scores_train = []\n",
    "scores = []\n",
    "sk = StratifiedKFold(n_splits=5,shuffle=True,random_state=0)\n",
    "for train_ind,test_ind in sk.split(X_data,Y_data):\n",
    "    \n",
    "    train_x=X_data.iloc[train_ind].values\n",
    "    train_y=Y_data.iloc[train_ind]\n",
    "    test_x=X_data.iloc[test_ind].values\n",
    "    test_y=Y_data.iloc[test_ind]\n",
    "    \n",
    "    model=build_model_xgb(train_x,train_y)\n",
    "    model.fit(train_x,train_y)\n",
    "    pred_train_xgb=model.predict(train_x)\n",
    "    pred_xgb=model.predict(test_x)\n",
    "    \n",
    "    score_train = mean_absolute_error(train_y,pred_train_xgb)\n",
    "    scores_train.append(score_train)\n",
    "    score = mean_absolute_error(test_y,pred_xgb)\n",
    "    scores.append(score)\n",
    "\n",
    "print('Train mae:',np.mean(score_train))\n",
    "print('Val mae',np.mean(scores))\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"\\n##五折交叉验证查看参数效果rfr\\nscores_train = []\\nscores = []\\nsk = StratifiedKFold(n_splits=5,shuffle=True,random_state=0)\\nfor train_ind,test_ind in sk.split(X_data,Y_data):\\n    \\n    train_x=X_data.iloc[train_ind].values\\n    train_y=Y_data.iloc[train_ind]\\n    test_x=X_data.iloc[test_ind].values\\n    test_y=Y_data.iloc[test_ind]\\n    \\n    model=build_model_rfr(train_x,train_y)\\n    model.fit(train_x,train_y)\\n    pred_train_rfr=model.predict(train_x)\\n    pred_rfr=model.predict(test_x)\\n    \\n    score_train = mean_absolute_error(train_y,pred_train_rfr)\\n    scores_train.append(score_train)\\n    score = mean_absolute_error(test_y,pred_rfr)\\n    scores.append(score)\\n\\nprint('Train mae:',np.mean(score_train))\\nprint('Val mae',np.mean(scores))\\n\""
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "##五折交叉验证查看参数效果rfr\n",
    "scores_train = []\n",
    "scores = []\n",
    "sk = StratifiedKFold(n_splits=5,shuffle=True,random_state=0)\n",
    "for train_ind,test_ind in sk.split(X_data,Y_data):\n",
    "    \n",
    "    train_x=X_data.iloc[train_ind].values\n",
    "    train_y=Y_data.iloc[train_ind]\n",
    "    test_x=X_data.iloc[test_ind].values\n",
    "    test_y=Y_data.iloc[test_ind]\n",
    "    \n",
    "    model=build_model_rfr(train_x,train_y)\n",
    "    model.fit(train_x,train_y)\n",
    "    pred_train_rfr=model.predict(train_x)\n",
    "    pred_rfr=model.predict(test_x)\n",
    "    \n",
    "    score_train = mean_absolute_error(train_y,pred_train_rfr)\n",
    "    scores_train.append(score_train)\n",
    "    score = mean_absolute_error(test_y,pred_rfr)\n",
    "    scores.append(score)\n",
    "\n",
    "print('Train mae:',np.mean(score_train))\n",
    "print('Val mae',np.mean(scores))\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "#改变n_estimators\n",
    "#10: 0min11s 2134/2146\n",
    "#30: 0min32s 664/749 \n",
    "#50: 0min51s 573/689\n",
    "#90: 1min28s 532/675\n",
    "#110:1min47s 515/669\n",
    "#160:2min36s 477/658"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "## 切分数据集（Train,test）进行模型训练，评价和预测\n",
    "x_train,x_test,y_train,y_test = train_test_split(X_data,Y_data,test_size=0.3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train lgb...\n",
      "MAE of val with lgb: 672.4114754656352\n"
     ]
    }
   ],
   "source": [
    "print('Train lgb...')\n",
    "model_lgb = build_model_lgb(x_train,y_train)\n",
    "y_lgb = model_lgb.predict(x_test)\n",
    "MAE_lgb = mean_absolute_error(y_test,y_lgb)\n",
    "print('MAE of val with lgb:',MAE_lgb)\n",
    "\n",
    "#print('Predict lgb...')\n",
    "model_lgb_pre = build_model_lgb(X_data,Y_data)\n",
    "Y_lgb = model_lgb_pre.predict(X_test)\n",
    "#print('Sta of Predict lgb:')\n",
    "#Sta_inf(Y_lgb) \n",
    "#150：677"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train xgb...\n",
      "[20:21:30] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n",
      "MAE of val with xgb: 661.3877872580429\n",
      "[20:22:00] WARNING: src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n"
     ]
    }
   ],
   "source": [
    "print('Train xgb...')\n",
    "model_xgb = build_model_xgb(x_train,y_train)\n",
    "y_xgb = model_xgb.predict(x_test)\n",
    "MAE_xgb = mean_absolute_error(y_test,y_xgb)\n",
    "print('MAE of val with xgb:',MAE_xgb)\n",
    "\n",
    "#print('Predict xgb...')\n",
    "model_xgb_pre = build_model_xgb(X_data,Y_data)\n",
    "Y_xgb = model_xgb_pre.predict(X_test)\n",
    "#print('Sta of Predict xgb:')\n",
    "#Sta_inf(subA_xgb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"\\nprint('Train sgd...')\\nmodel_sgd = build_model_sgd(x_train,y_train)\\ny_sgd = model_sgd.predict(x_test)\\nMAE_sgd = mean_absolute_error(y_test,y_sgd)\\nprint('MAE of val with sgd:',MAE_sgd)\\n\\n#print('Predict xgb...')\\nmodel_sgd_pre = build_model_sgd(X_data,Y_data)\\nY_lin = model_sgd_pre.predict(X_test)\\n#print('Sta of Predict xgb:')\\n#Sta_inf(subA_xgb)\\n#106117188032967\\n#775901829383128\\n#343632468679040\\n\""
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "print('Train sgd...')\n",
    "model_sgd = build_model_sgd(x_train,y_train)\n",
    "y_sgd = model_sgd.predict(x_test)\n",
    "MAE_sgd = mean_absolute_error(y_test,y_sgd)\n",
    "print('MAE of val with sgd:',MAE_sgd)\n",
    "\n",
    "#print('Predict xgb...')\n",
    "model_sgd_pre = build_model_sgd(X_data,Y_data)\n",
    "Y_lin = model_sgd_pre.predict(X_test)\n",
    "#print('Sta of Predict xgb:')\n",
    "#Sta_inf(subA_xgb)\n",
    "#106117188032967\n",
    "#775901829383128\n",
    "#343632468679040\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"\\nprint('Train gbr...')\\nmodel_gbr = build_model_gbr(x_train,y_train)\\ny_gbr = model_gbr.predict(x_test)\\nMAE_gbr = mean_absolute_error(y_test,y_gbr)\\nprint('MAE of val with gbr:',MAE_gbr)\\n\\n#print('Predict xgb...')\\nmodel_gbr_pre = build_model_gbr(X_data,Y_data)\\nY_gbr = model_gbr_pre.predict(X_test)\\n#print('Sta of Predict xgb:')\\n#Sta_inf(subA_xgb)\\n\""
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "print('Train gbr...')\n",
    "model_gbr = build_model_gbr(x_train,y_train)\n",
    "y_gbr = model_gbr.predict(x_test)\n",
    "MAE_gbr = mean_absolute_error(y_test,y_gbr)\n",
    "print('MAE of val with gbr:',MAE_gbr)\n",
    "\n",
    "#print('Predict xgb...')\n",
    "model_gbr_pre = build_model_gbr(X_data,Y_data)\n",
    "Y_gbr = model_gbr_pre.predict(X_test)\n",
    "#print('Sta of Predict xgb:')\n",
    "#Sta_inf(subA_xgb)\n",
    "'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train rfr...\n",
      "MAE of val with rfr: 665.6177123021164\n"
     ]
    }
   ],
   "source": [
    "print('Train rfr...')\n",
    "model_rfr = build_model_rfr(x_train,y_train)\n",
    "y_rfr = model_rfr.predict(x_test)\n",
    "MAE_rfr = mean_absolute_error(y_test,y_rfr)\n",
    "print('MAE of val with rfr:',MAE_rfr)\n",
    "\n",
    "#print('Predict xgb...')\n",
    "model_rfr_pre = build_model_rfr(X_data,Y_data)\n",
    "Y_rfr = model_rfr_pre.predict(X_test)\n",
    "#print('Sta of Predict xgb:')\n",
    "#Sta_inf(subA_xgb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MAE of mixed weight: 643.9948149110077\n"
     ]
    }
   ],
   "source": [
    "##使用rfr，xgb，lgb这三种模型混合\n",
    "sum_weight = MAE_rfr + MAE_xgb + MAE_lgb\n",
    "rfr_weight = 1-2*MAE_rfr/sum_weight\n",
    "xgb_weight = 1-2*MAE_xgb/sum_weight\n",
    "lgb_weight = 1-2*MAE_lgb/sum_weight\n",
    "y_mix = rfr_weight*y_rfr + xgb_weight*y_xgb + lgb_weight*y_lgb\n",
    "#y_mix = (1-MAE_rfr/(MAE_xgb+MAE_rfr))*y_rfr+(1-MAE_xgb/(MAE_xgb+MAE_rfr))*y_xgb\n",
    "y_mix[y_mix<0]=10 # 由于我们发现预测的最小值有负数，而真实情况下，price为负是不存在的，由此我们进行对应的后修正\n",
    "print('MAE of mixed weight:',mean_absolute_error(y_test,y_mix))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "预测结果中价格的统计数据如下：\n",
      "最小值： 10.0\n",
      "最大值： 90725.75410901807\n",
      "平均值: 5907.118228648457\n",
      "方差: 53263008.83378503\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYMAAAD4CAYAAAAO9oqkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAWwklEQVR4nO3df6xf9X3f8eerNhCalNiEC2K2NTvt1RYnUg25A3eZpgwy25CqphKRjKriZUzuMpCSrVpj2j9ofiDBtIYOLaFyg4uJ0hhK0mERM88iRFWk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T+iHwFDDUta5/Teeh2Ajw8a76EPB0W+a/0j69fioPwId5szfRe+n8ox0B/go4q9Xf0aZH2vz3di3/R21/n6Wrl8zpdB4BK4Dhdm78Nzq9gebkeQF8BvhB296v0OkRNCfPi16DX0chSZpTt4kkSeMwDCRJhoEkyTCQJGEYSJIwDCRJGAaSJOD/AfglpNGrcA2XAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "训练样本中价格的统计数据如下：\n",
      "最小值： 11\n",
      "最大值： 99999\n",
      "平均值: 5923.327333333334\n",
      "方差: 56279605.942732885\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY0AAAD4CAYAAAAQP7oXAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAUtElEQVR4nO3dbaxd1Z3f8e+v9piQTIlNcCLGRrVRrGkd1DbEIs6kGkVhCoZEMS9AMhoVN0NlNSVtZlppYpoXqEmQSDsaUtSECQqemCiDoUxaLAJ1LSAaVQoEM6Q8E9+BFO7AhJsaGDpRHpz598VZNzm5Ptd3cY/h+OH7kY7O3v+99t5r333tn/fe6xynqpAkqcffmXQHJEnHDkNDktTN0JAkdTM0JEndDA1JUrelk+7AkXbaaafVmjVrJt0NSTqmPPjggz+oqpULtTvuQmPNmjXs27dv0t2QpGNKkv/T087bU5KkboaGJKmboSFJ6mZoSJK6GRqSpG6GhiSpm6EhSepmaEiSuhkakqRux90nwsexZvs3Jrbv713zoYntW5J6eaUhSepmaEiSui0YGkl2JHkxyaNDtf+U5MkkDyf5b0mWDy27MslUkqeSnD9U39RqU0m2D9XXJrk/yf4kt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wCPtnX+C3Mexk74+D/AL0ZPncngL4Mp4L8CJ7X6m9r8VFt+5tD6n2rH9RRDo4WOxt8J4B8D+9q5/u8MRskc1+cZ+A/Ak61fX2UwAuq4Os/AzQye2fyUwZXB5W/EeZ1vH4d7+TUikqRu3p6SJHUzNCRJ3QwNSVI3Q0OS1M3QkCR1MzQkSd0MDUlSt/8PIaSJCKRLnwsAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "Y_mix = rfr_weight*Y_rfr + xgb_weight*Y_xgb + lgb_weight*Y_lgb\n",
    "Y_mix[Y_mix<0]=10\n",
    "print('预测结果中价格的统计数据如下：')\n",
    "get_info(Y_mix)\n",
    "plt.hist(Y_mix)\n",
    "plt.show()\n",
    "plt.close()\n",
    "print('训练样本中价格的统计数据如下：')\n",
    "get_info(Y_data)\n",
    "## 查看预测值的统计进行\n",
    "plt.hist(Y_data)\n",
    "plt.show()\n",
    "plt.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "sub = pd.DataFrame()\n",
    "sub['SaleID'] = X_test.index\n",
    "sub['price'] = Y_mix\n",
    "sub.to_csv('C:/Users/12594/Desktop/project/Final.csv',index=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
